Values
Conversion
ConvertJsonToTable
json_table = ConvertJsonToTable(json_str)Converts a JSON string to a table.
Parameters
| Parameter | Type | Description |
|---|---|---|
| json_str | String | JSON string |
Return Value
| Return Value | Type | Description |
|---|---|---|
| json_table | Table | Data table |
Example
Assume the value of json_str is:
{
"recipe": [
{
"pin": 1,
"PinHeight": 7.95
},
{
"pin": 2,
"PinHeight": 7.95
}
]
}Then the content of the output json_table is:
json_table = {
recipe = {
{
pin = 1,
PinHeight = 7.95
},
{
pin = 2,
PinHeight = 7.95
}
}
}ConvertTableToJson
json_str = ConvertTableToJson(json_table)Converts a table to a JSON string.
Parameters
| Parameter | Type | Description |
|---|---|---|
| json_table | Table | Data table |
Return Value
| Return Value | Type | Description |
|---|---|---|
| json_str | String | JSON string |
Example
Assume the value of json_table is:
json_table = {
recipe = {
{
pin = 1,
PinHeight = 7.95
},
{
pin = 2,
PinHeight = 7.95
}
}
}Then the content of the output json_str is:
{
"recipe": [
{
"pin": 1,
"PinHeight": 7.95
},
{
"pin": 2,
"PinHeight": 7.95
}
]
}HMI Data
WriteHmiData
success = WriteHmiData(table_name, fields, values)Writes data to the HMI database. Fields in fields correspond one-to-one with values in values.
Parameters
| Parameter | Type | Description |
|---|---|---|
| table_name | String | Name of the database table |
| fields | Array | List of field names (content is strings) |
| values | Array | List of values |
Return Value
| Return Value | Type | Description |
|---|---|---|
| success | Bool | Whether the operation is successful |
Global Variables
SetBoolVariable
SetBoolVariable(name, variable)Sets a global variable (Boolean type).
Parameters
| Parameter | Type | Description |
|---|---|---|
| name | String | Name of the global variable |
| variable | Bool | Value of the variable |
SetStringVariable
SetStringVariable(name, variable)Sets a global variable (String type).
Parameters
| Parameter | Type | Description |
|---|---|---|
| name | String | Name of the global variable |
| variable | String | Value of the variable |
SetIntVariable
SetIntVariable(name, variable)Sets a global variable (Integer type).
Parameters
| Parameter | Type | Description |
|---|---|---|
| name | String | Name of the global variable |
| variable | Integer | Value of the variable |
SetFloatVariable
SetFloatVariable(name, variable)Sets a global variable (Float type).
Parameters
| Parameter | Type | Description |
|---|---|---|
| name | String | Name of the global variable |
| variable | Number (Double-precision Float) | Value of the variable |
SetBoolArrayVariable
SetBoolArrayVariable(name, variable)Sets a global variable (Boolean Array type).
Parameters
| Parameter | Type | Description |
|---|---|---|
| name | String | Name of the global variable |
| variable | Array | Value of the variable |
SetStringArrayVariable
SetStringArrayVariable(name, variable)Sets a global variable (String Array type).
Parameters
| Parameter | Type | Description |
|---|---|---|
| name | String | Name of the global variable |
| variable | Array | Value of the variable |
SetIntArrayVariable
SetIntArrayVariable(name, variable)Sets a global variable (Integer Array type).
Parameters
| Parameter | Type | Description |
|---|---|---|
| name | String | Name of the global variable |
| variable | Array | Value of the variable |
SetFloatArrayVariable
SetFloatArrayVariable(name, variable)Sets a global variable (Float Array type).
Parameters
| Parameter | Type | Description |
|---|---|---|
| name | String | Name of the global variable |
| variable | Array | Value of the variable |
Script Output
SetInt
SetInt(name, n)Sets an integer to the script output.
Parameters
| Parameter | Type | Description |
|---|---|---|
| name | String | Name of the output variable |
| n | Int | Integer value |
SetFloat
SetFloat(name, f)Sets a float to the script output.
Parameters
| Parameter | Type | Description |
|---|---|---|
| name | String | Name of the output variable |
| f | Float | Float value |
SetBool
SetBool(name, b)Sets a Boolean value to the script output.
Parameters
| Parameter | Type | Description |
|---|---|---|
| name | String | Name of the output variable |
| b | Bool | Boolean value |
SetString
SetString(name, str)Sets a string to the script output.
Parameters
| Parameter | Type | Description |
|---|---|---|
| name | String | Name of the output variable |
| str | String | String value |
SetMatrix
SetMatrix(name, rows, cols, data)Sets a matrix to the script output.
Parameters
| Parameter | Type | Description |
|---|---|---|
| name | String | Name of the output variable |
| rows | Int | Number of rows in the matrix |
| cols | Int | Number of columns in the matrix |
| data | Array | Matrix data (represented in row-major order) |
SetIntArray
SetIntArray(name, array)Sets an integer array to the script output.
Parameters
| Parameter | Type | Description |
|---|---|---|
| name | String | Name of the output variable |
| array | Array | Integer array |
SetFloatArray
SetFloatArray(name, array)Sets a float array to the script output.
Parameters
| Parameter | Type | Description |
|---|---|---|
| name | String | Name of the output variable |
| array | Array | Float array |
SetBoolArray
SetBoolArray(name, array)Sets a Boolean array to the script output.
Parameters
| Parameter | Type | Description |
|---|---|---|
| name | String | Name of the output variable |
| array | Array | Boolean array |
SetStringArray
SetStringArray(name, array)Sets a string array to the script output.
Parameters
| Parameter | Type | Description |
|---|---|---|
| name | String | Name of the output variable |
| array | Array | String array |
